home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / zip / portfoli / bootst11.lzh / PF BOOTSTRAP VAXMODEM MISCC < prev    next >
Text File  |  1991-05-03  |  4KB  |  181 lines

  1. #include "xmodem.h"
  2.  
  3. /*  Print Help Message  */
  4. help()
  5.     {
  6.     fprintf(stderr, "Usage:  \txmodem ");
  7.     fprintf(stderr, "-[rb!rt!ra!sb!st!sa][options] filename\n");
  8.     fprintf(stderr, "Major Commands --");
  9.     fprintf(stderr, "\n\trb <-- Receive Binary");
  10.     fprintf(stderr, "\n\trt <-- Receive Text");
  11.     fprintf(stderr, "\n\tra <-- Receive Apple macintosh text");
  12.     fprintf(stderr, "\n\tsb <-- Send Binary");
  13.     fprintf(stderr, "\n\tst <-- Send Text");
  14.     fprintf(stderr, "\n\tsa <-- Send Apple macintosh text");
  15.     fprintf(stderr, "\nOptions --");
  16.     fprintf(stderr, "\n\ty  <-- Use YMODEM Batch Mode on transmit");
  17.     fprintf(stderr, "\n\tg  <-- Select YMODEM-G Mode on receive");
  18.     fprintf(stderr, "\n\tm  <-- Use MODEM7 Batch Mode on transmit");
  19.     fprintf(stderr, "\n\tk  <-- Use 1K packets on transmit");
  20.     fprintf(stderr, "\n\tc  <-- Select CRC mode on receive");
  21.     fprintf(stderr, "\n\tt  <-- Indicate a TOO BUSY Unix system");
  22.     fprintf(stderr, "\n\td  <-- Delete xmodem.log file before starting");
  23.     fprintf(stderr, "\n\tl  <-- (ell) Turn OFF Log File Entries");
  24.     fprintf(stderr, "\n\tx  <-- Include copious debugging information in log file");
  25.     fprintf(stderr, "\n\tp  <-- Use with SunOS tip ~C command");
  26.     fprintf(stderr, "\n\tw  <-- Wait before initial handshake");
  27.     fprintf(stderr, "\n\te  <-- Supress EOT confirmation");
  28.     fprintf(stderr, "\n\tn  <-- Allow mid-transfer CAN-CAN aborts");
  29.     fprintf(stderr, "\n");
  30.     }
  31.  
  32. /* get type of transmission requested (text or binary) */
  33. gettype(ichar)
  34. char ichar;
  35.     {
  36.     if (ichar == 't' || ichar == 'T')
  37.         return('t');
  38.     else if (ichar == 'b' || ichar == 'B')
  39.         return('b');
  40.     else if (ichar == 'a' || ichar == 'A')
  41.         return('a');
  42.     else
  43.         error("Invalid Send/Receive Parameter - not t or b", FALSE);
  44.     return('\0');
  45.     }
  46.  
  47. /* return a string containing transmission type */
  48. char *
  49. prtype(ichar)
  50. char ichar;
  51.     {
  52.     if (ichar == 't' || ichar == 'T')
  53.         return("text");
  54.     else if (ichar == 'b' || ichar == 'B')
  55.         return("binary");
  56.     else if (ichar == 'a' || ichar == 'A')
  57.         return("apple");
  58.     else
  59.         return("");
  60.     }
  61.  
  62. /* print error message and exit; if mode == TRUE, restore normal tty modes */
  63. error(msg, mode)
  64. char *msg;
  65. int mode;
  66.     {
  67.     if (mode)
  68.         restoremodes(TRUE);  /* put back normal tty modes */
  69.     fprintf(stderr, "\r\n%s\n", msg);
  70.     if ((LOGFLAG || DEBUG) && (LOGFP != NULL))
  71.         {   
  72.         fprintf(LOGFP, "XMODEM Fatal Error:  %s\n", msg);
  73.             fclose(LOGFP);
  74.         }
  75.     exit(-1);
  76.     }
  77.  
  78.  
  79. /* Construct a proper (i.e. pretty) sector count for messages */
  80.  
  81. char
  82. *sectdisp(recvsectcnt, bufsize, plus1)
  83. long recvsectcnt;
  84. int bufsize, plus1;
  85.     {
  86.     static char string[20];
  87.     if (plus1)
  88.         recvsectcnt += (bufsize == 128) ? 1 : 8;
  89.     if (bufsize == 128 || recvsectcnt == 0)
  90.         sprintf (string, "%d", recvsectcnt);
  91.     else
  92.         sprintf (string, "%d-%d", recvsectcnt-7, recvsectcnt);
  93.     return(string);
  94.     }
  95.  
  96. /* type out debugging info */
  97. xmdebug(str)
  98. char *str;
  99.     {
  100.     if (DEBUG && (LOGFP != NULL))
  101.         fprintf(LOGFP,"DEBUG: '%s'\n",str);
  102.     }
  103.  
  104. /* print elapsed time and rate of transfer in logfile */
  105.  
  106. int quant[] = { 60, 60, 24};    
  107. char sep[3][10] = { "second", "minute", "hour" };
  108.  
  109. prtime (numsect, seconds, fileid)
  110. long numsect;
  111. time_t seconds;
  112. FILE *fileid;
  113.  
  114. {
  115.     register int i;
  116.     register int Seconds;
  117.     int nums[3];
  118.     int rate;
  119.  
  120.     if (numsect == 0)
  121.         return(0);
  122.  
  123.     Seconds = (int)seconds;
  124.     Seconds = (Seconds > 0) ? Seconds : 0;
  125.  
  126.     rate = (Seconds != 0) ? 128 * numsect/Seconds : 0;
  127.  
  128.     for (i=0; i<3; i++) {
  129.         nums[i] = (Seconds % quant[i]);
  130.         Seconds /= quant[i];
  131.     }
  132.  
  133.     fprintf (fileid, "%ld Sectors Transfered in ", numsect);
  134.  
  135.     if (rate == 0)
  136.         fprintf (fileid, "0 seconds");
  137.     else
  138.         while (--i >= 0)
  139.             if (nums[i])
  140.                 fprintf (fileid, "%d %s%c ", nums[i], &sep[i][0],
  141.                     nums[i] == 1 ? ' ' : 's');
  142.     fprintf (fileid, "\n");
  143.  
  144.     if (rate != 0)
  145.         fprintf (fileid, "Transfer Rate = %d Characters per Second\n", rate);
  146.  
  147.     return(0);
  148. }
  149.  
  150. /* Print elapsed time estimate */
  151.  
  152. projtime (numsect, fd)
  153. long numsect;
  154. FILE *fd;
  155.     {
  156.     register int i;
  157.     register int seconds;
  158.     int nums[3];
  159.  
  160.     if (numsect == 0)
  161.         return (0);
  162.  
  163. /* constant below should really be 1280; reduced to 90% to account for time lost in overhead */
  164.  
  165.     seconds = 1422 * numsect / ttyspeed + 1;
  166.  
  167.     for (i=0; i<3; i++) {
  168.         nums[i] = (seconds % quant[i]);
  169.         seconds /= quant[i];
  170.     }
  171.  
  172.     fprintf (fd, "Estimated transmission time ");
  173.  
  174.     while (--i >= 0)
  175.         if (nums[i])
  176.             fprintf (fd, "%d %s%c ", nums[i], &sep[i][0],
  177.                 nums[i] == 1 ? ' ' : 's');
  178.     fprintf (fd, "\n");
  179.     return (0);
  180.     }
  181.